/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tabelmodel;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import model.Indikasi;

/**
 *
 * @author tashiba
 */
public class IndikasiTerpilihTableModel extends AbstractTableModel {

    private List<Indikasi> indiTer = new ArrayList<Indikasi>();

    public IndikasiTerpilihTableModel(List<Indikasi> indikasiTerpilih) {
        this.indiTer = indikasiTerpilih;
    }

    public void deleteIndikasiTerpilih(int row) {
        indiTer.remove(row);
        fireTableRowsDeleted(row, row);
    }

    public void updateIndikasiTerpilih(int row, Indikasi indikasiTerpilih) {
        indiTer.set(row, indikasiTerpilih);
        fireTableRowsUpdated(row, row);
    }

    public void addIndikasiTerpilih(Indikasi indikasiTerpilih) {
        indiTer.add(indikasiTerpilih);
        fireTableRowsInserted(getRowCount() - 1, getColumnCount() - 1);
    }

    public int getRowCount() {
        return indiTer.size();
    }

    public int getColumnCount() {
        return 1;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Indikasi b = indiTer.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return b.getNamaIndikasi();
            default:
                return "";
        }
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "INDIKASI";
            default:
                return "";
        }
    }
}

